<script setup>
import { ref } from 'vue'
import Button from './button.vue'
import { getLatestDownloadUrl } from './utils';

const props = defineProps(['platform'])

const url = ref("");
const label = ref(`下载 E3 for ${props.platform.label}`)
const isMac = props.platform.id.startsWith("osx_")
const isArm = props.platform.arch === "arm";

getLatestDownloadUrl(props.platform.path, isMac, isArm).then((appUrl) => {
  url.value = appUrl;
})

</script>

<template>
  <div class="inline mr-2">
    <Button :label="label" :href="url" v-if="url"></Button>
  </div>
</template>
